import { defineStore } from "pinia";
import { BonusListRes, BonusRes, NotifyListRes, NotifyMsgListRes } from "@/types/message.ts";

interface MessageState {
  bonus: BonusRes;
  message: NotifyListRes;
  messageList: NotifyMsgListRes[][];
  bonusList: BonusListRes[][];
  luckyReward: Record<string, boolean>;
  openCashRainStatus: boolean;
  popBannerList: []; //首页Banner弹窗列表
}

// const messageMockList = [
//   {
//     id: 1,
//     title: "Newcomer registration",
//     msgContent:
//       '{text:"registrationNewcomer registrationNewcomer registrationNewcomer registration",imgs: ["background.png"]}',
//     msgType: MsgTypeEnum.UserMsgTypeSystemNotify,
//     isRead: MessageReadEnum.READ,
//     createTime: "2023-08-08 UTC",
//   },
//   {
//     id: 2,
//     title: "Newcomer registration",
//     msgContent:
//       '{text:"registrationNewcomer registrationNewcomer registrationNewcomer registration",imgs: ["background.png"]}',
//     msgType: MsgTypeEnum.UserMsgTypeSystemNotify,
//     isRead: MessageReadEnum.READ,
//     createTime: "2023-08-08 UTC",
//   },
//   {
//     id: 3,
//     title: "Newcomer registration",
//     msgContent:
//       '{text:"registrationNewcomer registrationNewcomer registrationNewcomer registration",imgs: ["background.png"]}',
//     msgType: MsgTypeEnum.UserMsgTypeSystemNotify,
//     isRead: MessageReadEnum.READ,
//     createTime: "2023-08-08 UTC",
//   },
//   {
//     id: 4,
//     title: "Newcomer registration",
//     msgContent:
//       '{text:"registrationNewcomer registrationNewcomer registrationNewcomer registration",imgs: ["background.png"]}',
//     msgType: MsgTypeEnum.UserMsgTypeSystemNotify,
//     isRead: MessageReadEnum.READ,
//     createTime: "2023-08-08 UTC",
//   },
// ];

export const MessageStore = defineStore("messageStore", {
  state: (): MessageState => ({
    bonus: { list: [], total: 0, notReceived: 0 },
    message: {
      list: [],
      total: 0,
      notRead: 0,
    },
    messageList: [],
    bonusList: [],
    luckyReward: {},
    openCashRainStatus: false, //修改从个人中心那边的活动列表打开现金雨活动弹窗
    popBannerList: [],
  }),
  actions: {
    setState(data: Partial<MessageState>) {
      Object.assign(this, data);
    },
    setOpenCashRainStatus() {
      this.openCashRainStatus = this.openCashRainStatus ? false : true;
    },
    //保存弹窗列表
    setPopBannerList(this, list) {
      this.popBannerList = list;
    },
  },
});
